#!/bin/bash
NDK=/home/suka/legrand/android-ndk-r21b
ADDI_LDFLAGS="-fPIE -pie"
ADDI_CFLAGS="-fPIE -pie -march=armv7-a -mfloat-abi=softfp -mfpu=neon"
CPU=armv7-a
ARCH=arm
HOST=arm-linux
SYSROOT=$NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin
PREFIX=$(pwd)/out_android/
WORK=$(pwd)/work_android/ffmpeg/
SRC_COED=$(pwd)/../ffmpeg/
x264=$(pwd)/x264/android/$CPU
export PATH=$x264/bin:$PATH
export PATH=$x264/include:$PATH
export PATH=$x264/lib:$PATH
export PKG_CONFIG_PATH=$x264/lib/pkgconfig:$PKG_CONFIG_PATH
configure()
{
    $SRC_COED/configure \
    --prefix=$PREFIX \
	--toolchain=clang-usan \
    --enable-cross-compile \
    --target-os=android \
    --arch=$ARCH \
    --sysroot=$SYSROOT \
	--cc=$TOOLCHAIN/armv7a-linux-androideabi21-clang \
	--cxx=$TOOLCHAIN/armv7a-linux-androideabi21-clang++ \
    --strip=$TOOLCHAIN/arm-linux-androideabi-strip \
    --extra-cflags="$ADDI_CFLAGS" \
    --extra-ldflags="$ADDI_LDFLAGS" \
    --disable-encoders \
    --disable-decoders \
    --disable-avdevice \
    --disable-static \
    --disable-doc \
    --disable-ffplay \
    --disable-network \
    --disable-doc \
    --disable-symver \
	--disable-ffprobe \
    --disable-jni \
    --disable-libx264 \
    --enable-shared 
	

}

build()
{
	cd $WORK
    configure
    make clean
    make -j4
    make install
}
if [ ! -d $WORK ]; then
	mkdir $WORK
fi
build
